home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Game / R / ROBOT WARRIORS 1.0.1.CPT / Robot Warriors / Example Robots / Seeker < prev    next >
Text File  |  1991-08-26  |  3KB  |  112 lines

  1. ; Robot Name:  Seeker
  2. ;
  3. ;   Seeks out and destroys other robots. Cloak if damaged or if a close robot
  4. ;   is detected.  Tries to conserve fuel by not cloaking as much when nearly
  5. ;   out of fuel.
  6.  
  7. CPU_SPEED 1
  8. ARMOR 0
  9. FIRE_RATE 2
  10. ENGINE_SIZE 0
  11. RADAR_RANGE 0
  12. CLOAKING 1
  13. FUEL_CAPACITY 2
  14.  
  15. allocate oldaim
  16. allocate old_damage
  17.  
  18.  
  19.  
  20.     seeker_interrupt to time_int_xfer
  21.     1 to time_int_mask
  22.     aim - 4 to aim
  23.  
  24.     ;Start off towards the center of the arena
  25.     if x < 180 then
  26.       if y < 150 then
  27.         135 to direction  ;in upper left, move towards lower right
  28.       else
  29.         45 to direction   ;in lower left, move towards upper right
  30.       end
  31.     else
  32.       if y < 150 then
  33.         225 to direction  ;in upper right, move towards lower left
  34.       else
  35.         315 to direction  ;in lower right, moved towards upper left
  36.       end
  37.     end
  38.     20 to speed
  39.  
  40. again
  41.     repeat
  42.       if speed = 0 then
  43.         gosub cloak_me
  44.         120 + direction to direction  ;Move away to possible collision source
  45.         20 to speed
  46.       end
  47.       if X < 20 then 90 to direction
  48.       if Y < 20 then 180 to direction
  49.       if X > 360 then 270 to direction
  50.       if Y > 290 then 0 to direction
  51.       if damage <> old_damage then gosub cloak_me
  52.       aim + 3 to aim
  53.       aim to radar
  54.     until radar > 0
  55.  
  56.     if shot > 0 then
  57.       aim - 9 to aim
  58.     else
  59.       aim to oldaim
  60.       300/radar + aim - 1 to aim  ;Try to hit the center of the enemy robot
  61.       ;Usually enemy robots are moving away, shoot ahead of them
  62.       radar / 10 + radar to shot
  63.       aim to direction
  64.       if radar < 80 then gosub cloak_me
  65.       
  66.       ;Try to avoid hitting the other robot
  67.       
  68.       if radar < 110 then aim - 10 to direction
  69.       if radar < 85 then aim - 30 to direction
  70.       if radar < 45 then 
  71.             aim - 120 to direction
  72.       else
  73.         if radar < 85 then aim - 40 to direction
  74.       end
  75.             
  76.       oldaim to aim
  77.       aim - 4 to aim
  78.     end
  79. goto again
  80.  
  81.  
  82. ;Try to hide while conserving fuel
  83.  
  84. cloak_me
  85.     damage to old_damage
  86.     if damage > 75 then  ;about to die
  87.         fuel/50 to cloak
  88.         if damage > 90 then cloak + 10 to cloak  ;really about to die
  89.     else
  90.         if fuel < 150 then  ;almost out of fuel don't cloak to much
  91.             2 to cloak       ;Only cloak enough to possibly trick other robot.  
  92.             if damage > 95 then 5 to cloak  ;Also about to die, oh no!
  93.         else
  94.             if fuel > 1500 then   ;Lots of fuel, clock for awhile
  95.                 12 to cloak
  96.             else
  97.                 if fuel > 750 then   ;Not as much fuel, don't cloak as long
  98.                     10 to cloak
  99.                 else
  100.                      5 to cloak     ;Not much fuel
  101.                 end
  102.             end
  103.         end
  104.     end
  105. return
  106.  
  107.  
  108. seeker_interrupt
  109.     if cloak > 0 then cloak - 1 to cloak
  110. endint
  111.  
  112.